package CreativePattern.FactoryPattern.Factory.staticFactoryMethod;

import CreativePattern.FactoryPattern.Factory.staticFactoryMethod.entity.HatchbackCar;
import CreativePattern.FactoryPattern.Factory.staticFactoryMethod.entity.JeepCar;
import CreativePattern.FactoryPattern.Factory.staticFactoryMethod.entity.SportCar;

//简单工厂方法
public class CarFactory {
    public static ICar getCar(String carType) {
        if (carType == null) {
            return null;
        }
        if (carType.equalsIgnoreCase("SPORT")) {
            return new SportCar();
        } else if (carType.equalsIgnoreCase("JeepCar")) {
            return new JeepCar();
        } else if (carType.equalsIgnoreCase("HatchbackCar")) {
            return new HatchbackCar();
        }
        return null;
    }
}
